package org.ade.monak.anak.service.gate.monak;

import org.ade.monak.anak.entity.Ortu;
import org.ade.monak.anak.service.DatabaseThreadService;
import org.ade.monak.anak.service.storage.DatabaseManagerAnak;

import android.content.Context;

public class ReceiverTrackingMode {

	public ReceiverTrackingMode(Context context, DatabaseThreadService databaseThread, Ortu ortu){
		this.databaseManager 	= new DatabaseManagerAnak(context);
		this.senderKonfirmasi	= new SenderKonfirmasi(context, ortu);
		this.ortu 				= ortu;
		this.databaseThread		= databaseThread;
	}
	
	public void startTrackingMode(){
		databaseThread.addDatabaseThread(new Runnable() {
			public void run() {
				ortu.setTrack(true);
				databaseManager.setTrackOrtu(ortu);		
			}
		});
		senderKonfirmasi.sendKonfirmasiStartTracking();
	}
	
	public void stopTrackingMode(){
		databaseThread.addDatabaseThread(new Runnable() {
			public void run() {
				ortu.setTrack(false);
				databaseManager.setTrackOrtu(ortu);
			}
		});
		senderKonfirmasi.sendKonfirmasiStopTracking();
	}
	
	private final DatabaseThreadService	databaseThread;
	private final DatabaseManagerAnak 	databaseManager; 
	private final SenderKonfirmasi		senderKonfirmasi;
	private final Ortu					ortu;
}
